﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using TRPOP.Common;
using TRPOP.CRM.Component.Business;
using TRPOP.CRM.Component.Common;

namespace TRPOP.CRM.Web
{
    public partial class MyCompany_list : BaseAdmin
    {
        #region 页面事件
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }

        /// <summary>
        /// 分页触发此事件（分页采用post方法传递数据）
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void UC_PagerChanged(object sender, EventArgs e)
        {
            BindData();
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            string strCondation = string.Empty;

            if (!txtName.Text.IsEmpty() && txtName.Text != "输入关键字")
            {
                strCondation = string.Format(" AND (  nvcCompanyName LIKE '%{0}%'  OR nvcRegisterAdress LIKE '%{0}%'  OR nvcContactPhone LIKE '%{0}%' OR nvcContactName LIKE '%{0}%'  OR nvcEmployeeName  LIKE '%{0}%' )  ", txtName.Text.Trim().HtmlEncode().SQLFilter());
            }

            ViewState["SearchCondation"] = strCondation;

            Pager.Page_ReLoad();

            BindData();
        }
        #endregion

        #region 页面方法
        /// <summary>
        /// 绑定管理员信息列表
        /// </summary>
        protected void BindData()
        {
            int RecordCount = 0;

            string strCondition = string.Empty;
            if (ViewState["SearchCondation"] != null)
            {
                strCondition = ViewState["SearchCondation"].ToString();
            }

            strCondition += " AND [iEmployeeFollowup]= " + base.GetCurrentEmployeeInfo().iEmployeeID;

            strCondition += " AND [icompanystatus] = 1 ";

            rptList.DataSource = CompanyManage.GetRemindExtraInfoListByPager(Pager.CurrentPage, Pager.PageSize, strCondition, string.Empty, out RecordCount);

            rptList.DataBind();

            Pager.RecordCount = RecordCount;
        }
        #endregion
    }
}